$(function () {
    var contextPath = getContextPath();
    var url = contextPath+"/CommentController/getComment.press";
    var data ={};
    $.post(url,data,function (result) {
        var Allhtml ="";
        var Pagehtml ="";
        //动态添加全部评论
        for(var i =0;i<result.allCommentList.length;i++){
            Allhtml = Allhtml +
                "<tr><td>"+"<input name='dataItem' onclick='checkAll(this)' type='checkbox' />" +
                "<input type='hidden' class='hidden' value='"+result.allCommentList[i].comment_id+"'/></td>" ;
            var fromwho=result.allCommentList[i].aUser.user_nickname;
            if(fromwho==null || fromwho == "")
                Allhtml = Allhtml + "<td>"+""+"</td>";
            else
                Allhtml = Allhtml + "<td>"+result.allCommentList[i].aUser.user_nickname+"</td>";
            var text=result.allCommentList[i].comment_text;
            if(text==null || text == "")
                Allhtml = Allhtml + "<td>"+""+"</td>";
            else
                Allhtml = Allhtml + "<td>"+result.allCommentList[i].comment_text+"</td>";
            Allhtml = Allhtml +
                "<td>"+result.allCommentList[i].aContent.content_title+"</td>";
            var towho=result.allCommentList[i].aCommentParent.aUser.user_nickname;
            if(towho==null || towho == "")
                Allhtml = Allhtml + "<td>"+""+"</td>";
            else
                Allhtml = Allhtml +  "<td>"+result.allCommentList[i].aCommentParent.aUser.user_nickname+"</td>" ;
            Allhtml = Allhtml +
                "<td>"+result.allCommentList[i].comment_date+"</td>" +
                "<td>"+result.allCommentList[i].comment_status+"</td>" ;
            var status=result.allCommentList[i].comment_status;
            if(status=="已置顶")
                Allhtml = Allhtml +"<td>"+"<button type='button' class='canceltop btn btn-success'>取消置顶</button>&nbsp;&nbsp;<a type='button' href="+getContextPath()+'/CommentController/reply.press?comment_id='+result.allCommentList[i].comment_id+" class='btn btn-info'>回复</a>&nbsp;&nbsp;<button type='button' class='movetotrash btn btn-danger '>删除</button>"+"</td></tr>"
            else if(status=="审核通过")
                Allhtml = Allhtml +"<td>"+"<button type='button' class='puttop btn btn-primary'>置顶</button>&nbsp;&nbsp;<a type='button' href="+getContextPath()+'/CommentController/reply.press?comment_id='+result.allCommentList[i].comment_id+" class='btn btn-info'>回复</a>&nbsp;&nbsp;<button type='button' class='movetotrash btn btn-danger'>删除</button>"+"</td></tr>"
            else if(status=="未审核")
                Allhtml = Allhtml +"<td>"+"<button type='button' class='pass btn btn-success'>通过</button>&nbsp;&nbsp;<button type='button' class='nopass btn btn-warning'>不通过</button>"+"</td></tr>"
        }
        Pagehtml=Pagehtml+             
            "<tr><td colspan='8'>"+
            "<div class='pull-left'>"+
            "</div>" +
            "<div class='pull-right king-page-box'> " +
            "<p class='pull-left mt15'>共<span id='total'>12</span>条记录,当前第<span id='cur_page'>1</span>/<span id='total_page'>3</span>页</p> " +
            "<div class='holder pull-right ml15'> " +
            "<div class='king-jP'>" +
            "<a class='jp-previous jp-disabled'>«</a>" +
            "<a class='jp-current'>1</a>" +
            "<span class='jp-hidden'>...</span>" +
            "<a href='#' class=''>2</a><span class='jp-hidden'>...</span><a>3</a><a class='jp-next'>»</a></div> " +
            "</div> </div> </td> </tr>"

        $("#datas").html(Allhtml);
        $("#datanum").html(Pagehtml);
        $("#all").html("("+ result.commentCount+")");
        $("#published").html("("+ result.publishedCount+")");
        $("#check").html("("+ result.checkCount+")");
        $("#trash").html("("+ result.commentBinCount+")");
        // 设置分页
        $("#table_demo3 .holder").jPages({
            containerID : "datas",
            previous : "«",
            next : "»",
            perPage : 4,
            delay : 10,
            callback: function(pages, items){
                $('#total').text(items.count);
                $('#cur_page').text(pages.current);
                $('#total_page').text(pages.count);
            }
        });
        //全选
        $('#table_demo3').find('.select-all').on('click', function(){
            if(this.checked){
                $('#table_demo3 :checkbox').prop('checked',true);
            }else{
                $('#table_demo3 :checkbox').prop('checked',false);
            }
        });
        $('#table_demo3').find(':checkbox').on('click', function(){
            if(!this.checked){
                $('#table_demo3').find('.select-all').prop('checked',false);
            }
        });
        //删除
        $(".movetotrash").click(function () {
            var commentId = $(this).parent().prevAll().find(".hidden").attr("value");
            var url2 = getContextPath()+"/CommentController/giveTrash.press";
            if(confirm('确定要删除？')){
                $(this).closest('tr').remove();

                $.post(url2, {"comment_id": commentId}, function (result) {
                    if (result.msg == "yes") {
                        alert("删除成功！")
                        window.location.reload();
                    } else {
                        alert("系统错误！删除失败！");
                    }
                }, "json");
            }
        });
        //取消置顶
        $(".canceltop").click(function () {
            var commentId = $(this).parent().prevAll().find(".hidden").attr("value");
            var url3 = getContextPath()+"/CommentController/cancelStick.press";
            $.post(url3, {"comment_id": commentId}, function (result) {
                if (result.msg == "yes") {
                    alert("取消置顶成功！")
                    window.location.reload();
                } else {
                    alert("系统错误！取消置顶失败！");
                }
            }, "json");
        });
        //置顶
        $(".puttop").click(function () {
            var commentId = $(this).parent().prevAll().find(".hidden").attr("value");
            var url4 = getContextPath()+"/CommentController/putStick.press";
            $.post(url4, {"comment_id": commentId}, function (result) {
                if (result.msg == "yes") {
                    alert("置顶成功！")
                    window.location.reload();
                } else {
                    alert("系统错误！置顶失败！");
                }
            }, "json");
        });
        
        //通过
        $(".pass").click(function () {
            var commentId = $(this).parent().prevAll().find(".hidden").attr("value");
            var url5 = getContextPath()+"/CommentController/passComment.press";
            $.post(url5, {"comment_id": commentId}, function (result) {
                if (result.msg == "yes") {
                    alert("操作成功！")
                    window.location.reload();
                } else {
                    alert("系统错误！操作失败！");
                }
            }, "json");
        });
        //审核不通过
        $(".nopass").click(function () {
            var commentId = $(this).parent().prevAll().find(".hidden").attr("value");
            var url6 = getContextPath()+"/CommentController/nopassComment.press";
            $.post(url6, {"comment_id": commentId}, function (result) {
                if (result.msg == "yes") {
                    alert("操作成功！")
                    window.location.reload();
                } else {
                    alert("系统错误！操作失败！");
                }
            }, "json");
        });
    },"json");
    
    $("#allcomm").click(function () {
        var data ={};
        $.post(url,data,function (result) {
            var Allhtml ="";
            var Pagehtml ="";
            //动态添加全部评论
            for(var i =0;i<result.allCommentList.length;i++){
                Allhtml = Allhtml +
                    "<tr><td>"+"<input name='dataItem' onclick='checkAll(this)' type='checkbox' />" +
                    "<input type='hidden' class='hidden' value='"+result.allCommentList[i].comment_id+"'/></td>" ;
                var fromwho=result.allCommentList[i].aUser.user_nickname;
                if(fromwho==null || fromwho == "")
                    Allhtml = Allhtml + "<td>"+""+"</td>";
                else
                    Allhtml = Allhtml + "<td>"+result.allCommentList[i].aUser.user_nickname+"</td>";
                var text=result.allCommentList[i].comment_text;
                if(text==null || text == "")
                    Allhtml = Allhtml + "<td>"+""+"</td>";
                else
                    Allhtml = Allhtml + "<td>"+result.allCommentList[i].comment_text+"</td>";
                Allhtml = Allhtml +
                    "<td>"+result.allCommentList[i].aContent.content_title+"</td>";
                var towho=result.allCommentList[i].aCommentParent.aUser.user_nickname;
                if(towho==null || towho == "")
                    Allhtml = Allhtml + "<td>"+""+"</td>";
                else
                    Allhtml = Allhtml +  "<td>"+result.allCommentList[i].aCommentParent.aUser.user_nickname+"</td>" ;
                Allhtml = Allhtml +
                    "<td>"+result.allCommentList[i].comment_date+"</td>" +
                    "<td>"+result.allCommentList[i].comment_status+"</td>" ;
                var status=result.allCommentList[i].comment_status;
                if(status=="已置顶")
                    Allhtml = Allhtml +"<td>"+"<button type='button' class='canceltop btn btn-success'>取消置顶</button>&nbsp;&nbsp;<a type='button' href="+getContextPath()+'/CommentController/reply.press?comment_id='+result.allCommentList[i].comment_id+" class='btn btn-info'>回复</a>&nbsp;&nbsp;<button type='button' class='movetotrash btn btn-danger '>删除</button>"+"</td></tr>"
                else if(status=="审核通过")
                    Allhtml = Allhtml +"<td>"+"<button type='button' class='puttop btn btn-primary'>置顶</button>&nbsp;&nbsp;<a type='button' href="+getContextPath()+'/CommentController/reply.press?comment_id='+result.allCommentList[i].comment_id+" class='btn btn-info'>回复</a>&nbsp;&nbsp;<button type='button' class='movetotrash btn btn-danger'>删除</button>"+"</td></tr>"
                else if(status=="未审核")
                    Allhtml = Allhtml +"<td>"+"<button type='button' class='pass btn btn-success'>通过</button>&nbsp;&nbsp;<button type='button' class='nopass btn btn-warning'>不通过</button>"+"</td></tr>"
            }
            Pagehtml=Pagehtml+
                "<tr><td colspan='8'>"+
                "<div class='pull-left'>"+
                "</div>" +
                "<div class='pull-right king-page-box'> " +
                "<p class='pull-left mt15'>共<span id='total'>12</span>条记录,当前第<span id='cur_page'>1</span>/<span id='total_page'>3</span>页</p> " +
                "<div class='holder pull-right ml15'> " +
                "<div class='king-jP'>" +
                "<a class='jp-previous jp-disabled'>«</a>" +
                "<a class='jp-current'>1</a>" +
                "<span class='jp-hidden'>...</span>" +
                "<a href='#' class=''>2</a><span class='jp-hidden'>...</span><a>3</a><a class='jp-next'>»</a></div> " +
                "</div> </div> </td> </tr>"

            $("#datas").html(Allhtml);
            $("#datanum").html(Pagehtml);
            // 设置分页
            $("#table_demo3 .holder").jPages({
                containerID : "datas",
                previous : "«",
                next : "»",
                perPage : 4,
                delay : 10,
                callback: function(pages, items){
                    $('#total').text(items.count);
                    $('#cur_page').text(pages.current);
                    $('#total_page').text(pages.count);
                }
            });
            //全选
            $('#table_demo3').find('.select-all').on('click', function(){
                if(this.checked){
                    $('#table_demo3 :checkbox').prop('checked',true);
                }else{
                    $('#table_demo3 :checkbox').prop('checked',false);
                }
            });
            $('#table_demo3').find(':checkbox').on('click', function(){
                if(!this.checked){
                    $('#table_demo3').find('.select-all').prop('checked',false);
                }
            });
            //删除
            $(".movetotrash").click(function () {
                var commentId = $(this).parent().prevAll().find(".hidden").attr("value");
                var url2 = getContextPath()+"/CommentController/giveTrash.press";
                if(confirm('确定要删除？')){
                    $(this).closest('tr').remove();

                    $.post(url2, {"comment_id": commentId}, function (result) {
                        if (result.msg == "yes") {
                            alert("删除成功！")
                            window.location.reload();
                        } else {
                            alert("系统错误！删除失败！");
                        }
                    }, "json");
                }
            });
            //取消置顶
            $(".canceltop").click(function () {
                var commentId = $(this).parent().prevAll().find(".hidden").attr("value");
                var url3 = getContextPath()+"/CommentController/cancelStick.press";
                $.post(url3, {"comment_id": commentId}, function (result) {
                    if (result.msg == "yes") {
                        alert("取消置顶成功！")
                        window.location.reload();
                    } else {
                        alert("系统错误！取消置顶失败！");
                    }
                }, "json");
            });
            //置顶
            $(".puttop").click(function () {
                var commentId = $(this).parent().prevAll().find(".hidden").attr("value");
                var url4 = getContextPath()+"/CommentController/putStick.press";
                $.post(url4, {"comment_id": commentId}, function (result) {
                    if (result.msg == "yes") {
                        alert("置顶成功！")
                        window.location.reload();
                    } else {
                        alert("系统错误！置顶失败！");
                    }
                }, "json");
            });
            //通过
            $(".pass").click(function () {
                var commentId = $(this).parent().prevAll().find(".hidden").attr("value");
                var url5 = getContextPath()+"/CommentController/passComment.press";
                $.post(url5, {"comment_id": commentId}, function (result) {
                    if (result.msg == "yes") {
                        alert("操作成功！")
                        window.location.reload();
                    } else {
                        alert("系统错误！操作失败！");
                    }
                }, "json");
            });
            //审核不通过
            $(".nopass").click(function () {
                var commentId = $(this).parent().prevAll().find(".hidden").attr("value");
                var url6 = getContextPath()+"/CommentController/nopassComment.press";
                $.post(url6, {"comment_id": commentId}, function (result) {
                    if (result.msg == "yes") {
                        alert("操作成功！")
                        window.location.reload();
                    } else {
                        alert("系统错误！操作失败！");
                    }
                }, "json");
            });
        },"json");
    });
    $("#publishedcomm").click(function () {
        var data ={};
        $.post(url,data,function (result) {
            var Publishedhtml ="";
            var Pagehtml ="";
            //动态添加已发布评论
            for(var i =0;i<result.publishedList.length;i++){
                Publishedhtml = Publishedhtml +
                    "<tr><td>"+"<input name='dataItem' onclick='checkAll(this)' type='checkbox' />" +
                    "<input type='hidden' class='hidden' value='"+result.publishedList[i].comment_id+"'/></td>" ;
                var fromwho=result.publishedList[i].aUser.user_nickname;
                if(fromwho==null || fromwho == "")
                    Publishedhtml = Publishedhtml + "<td>"+""+"</td>";
                else
                    Publishedhtml = Publishedhtml + "<td>"+result.publishedList[i].aUser.user_nickname+"</td>";
                var text=result.publishedList[i].comment_text;
                if(text==null || text == "")
                    Publishedhtml = Publishedhtml + "<td>"+""+"</td>";
                else
                    Publishedhtml = Publishedhtml + "<td>"+result.publishedList[i].comment_text+"</td>";
                Publishedhtml = Publishedhtml +
                    "<td>"+result.publishedList[i].aContent.content_title+"</td>";
                var towho=result.publishedList[i].aCommentParent.aUser.user_nickname;
                if(towho==null || towho == "")
                    Publishedhtml = Publishedhtml + "<td>"+""+"</td>";
                else
                    Publishedhtml = Publishedhtml +  "<td>"+result.publishedList[i].aCommentParent.aUser.user_nickname+"</td>" ;
                Publishedhtml = Publishedhtml +
                    "<td>"+result.publishedList[i].comment_date+"</td>" +
                    "<td>"+result.publishedList[i].comment_status+"</td>" ;
                var status=result.publishedList[i].comment_status;
                if(status=="已置顶")
                    Publishedhtml = Publishedhtml +"<td>"+"<button type='button' class='canceltop btn btn-success'>取消置顶</button>&nbsp;&nbsp;<a type='button' href="+getContextPath()+'/CommentController/reply.press?comment_id='+result.allCommentList[i].comment_id+" class='btn btn-info'>回复</a>&nbsp;&nbsp;<button type='button' class='movetotrash btn btn-danger '>删除</button>"+"</td></tr>"
                else if(status=="审核通过")
                    Publishedhtml = Publishedhtml +"<td>"+"<button type='button' class='puttop btn btn-primary'>置顶</button>&nbsp;&nbsp;<a type='button' href="+getContextPath()+'/CommentController/reply.press?comment_id='+result.allCommentList[i].comment_id+" class='btn btn-info'>回复</a>&nbsp;&nbsp;<button type='button' class='movetotrash btn btn-danger'>删除</button>"+"</td></tr>"
                 }
            Pagehtml=Pagehtml+
                "<tr><td colspan='8'>"+
                "<div class='pull-left'>"+
                "</div>" +
                "<div class='pull-right king-page-box'> " +
                "<p class='pull-left mt15'>共<span id='total'>12</span>条记录,当前第<span id='cur_page'>1</span>/<span id='total_page'>3</span>页</p> " +
                "<div class='holder pull-right ml15'> " +
                "<div class='king-jP'>" +
                "<a class='jp-previous jp-disabled'>«</a>" +
                "<a class='jp-current'>1</a>" +
                "<span class='jp-hidden'>...</span>" +
                "<a href='#' class=''>2</a><span class='jp-hidden'>...</span><a>3</a><a class='jp-next'>»</a></div> " +
                "</div> </div> </td> </tr>"

            $("#datas").html(Publishedhtml);
            $("#datanum").html(Pagehtml);
            // 设置分页
            $("#table_demo3 .holder").jPages({
                containerID : "datas",
                previous : "«",
                next : "»",
                perPage : 4,
                delay : 10,
                callback: function(pages, items){
                    $('#total').text(items.count);
                    $('#cur_page').text(pages.current);
                    $('#total_page').text(pages.count);
                }
            });
            //全选
            $('#table_demo3').find('.select-all').on('click', function(){
                if(this.checked){
                    $('#table_demo3 :checkbox').prop('checked',true);
                }else{
                    $('#table_demo3 :checkbox').prop('checked',false);
                }
            });
            $('#table_demo3').find(':checkbox').on('click', function(){
                if(!this.checked){
                    $('#table_demo3').find('.select-all').prop('checked',false);
                }
            });
            //删除
            $(".movetotrash").click(function () {
                var commentId = $(this).parent().prevAll().find(".hidden").attr("value");
                var url2 = getContextPath()+"/CommentController/giveTrash.press";
                if(confirm('确定要删除？')){
                    $(this).closest('tr').remove();

                    $.post(url2, {"comment_id": commentId}, function (result) {
                        if (result.msg == "yes") {
                            alert("删除成功！")
                            window.location.reload();
                        } else {
                            alert("系统错误！删除失败！");
                        }
                    }, "json");
                }
            });
            //取消置顶
            $(".canceltop").click(function () {
                var commentId = $(this).parent().prevAll().find(".hidden").attr("value");
                var url3 = getContextPath()+"/CommentController/cancelStick.press";
                $.post(url3, {"comment_id": commentId}, function (result) {
                    if (result.msg == "yes") {
                        alert("取消置顶成功！")
                        window.location.reload();
                    } else {
                        alert("系统错误！取消置顶失败！");
                    }
                }, "json");
            });
            //置顶
            $(".puttop").click(function () {
                var commentId = $(this).parent().prevAll().find(".hidden").attr("value");
                var url4 = getContextPath()+"/CommentController/putStick.press";
                $.post(url4, {"comment_id": commentId}, function (result) {
                    if (result.msg == "yes") {
                        alert("置顶成功！")
                        window.location.reload();
                    } else {
                        alert("系统错误！置顶失败！");
                    }
                }, "json");
            });
        },"json");
    });
    $("#checkcomm").click(function () {
        var data ={};
        $.post(url,data,function (result) {
            var Checkhtml ="";
            var Pagehtml ="";
            //动态添加待审核评论
            for(var i =0;i<result.checkList.length;i++){
                Checkhtml = Checkhtml +
                    "<tr><td>"+"<input name='dataItem' onclick='checkAll(this)' type='checkbox' />" +
                    "<input type='hidden' class='hidden' value='"+result.checkList[i].comment_id+"'/></td>" ;
                var fromwho=result.checkList[i].aUser.user_nickname;
                if(fromwho==null || fromwho == "")
                    Checkhtml = Checkhtml + "<td>"+""+"</td>";
                else
                    Checkhtml = Checkhtml + "<td>"+result.checkList[i].aUser.user_nickname+"</td>";
                var text=result.checkList[i].comment_text;
                if(text==null || text == "")
                    Checkhtml = Checkhtml + "<td>"+""+"</td>";
                else
                    Checkhtml = Checkhtml + "<td>"+result.checkList[i].comment_text+"</td>";
                Checkhtml = Checkhtml +
                    "<td>"+result.checkList[i].aContent.content_title+"</td>";
                var towho=result.checkList[i].aCommentParent.aUser.user_nickname;
                if(towho==null || towho == "")
                    Checkhtml = Checkhtml + "<td>"+""+"</td>";
                else
                    Checkhtml = Checkhtml +  "<td>"+result.checkList[i].aCommentParent.aUser.user_nickname+"</td>" ;
                Checkhtml = Checkhtml +
                    "<td>"+result.checkList[i].comment_date+"</td>" +
                    "<td>"+result.checkList[i].comment_status+"</td>" ;
                var status=result.checkList[i].comment_status;

                Checkhtml = Checkhtml +"<td>"+"<button type='button' class='pass btn btn-success'>通过</button>&nbsp;&nbsp;<button type='button' class='nopass btn btn-warning'>不通过</button>"+"</td></tr>"
            }
            Pagehtml=Pagehtml+
                "<tr><td colspan='8'>"+
                "<div class='pull-left'>"+
                "</div>" +
                "<div class='pull-right king-page-box'> " +
                "<p class='pull-left mt15'>共<span id='total'>12</span>条记录,当前第<span id='cur_page'>1</span>/<span id='total_page'>3</span>页</p> " +
                "<div class='holder pull-right ml15'> " +
                "<div class='king-jP'>" +
                "<a class='jp-previous jp-disabled'>«</a>" +
                "<a class='jp-current'>1</a>" +
                "<span class='jp-hidden'>...</span>" +
                "<a href='#' class=''>2</a><span class='jp-hidden'>...</span><a>3</a><a class='jp-next'>»</a></div> " +
                "</div> </div> </td> </tr>"

            $("#datas").html(Checkhtml);
            $("#datanum").html(Pagehtml);
            // 设置分页
            $("#table_demo3 .holder").jPages({
                containerID : "datas",
                previous : "«",
                next : "»",
                perPage : 4,
                delay : 10,
                callback: function(pages, items){
                    $('#total').text(items.count);
                    $('#cur_page').text(pages.current);
                    $('#total_page').text(pages.count);
                }
            });
            //全选
            $('#table_demo3').find('.select-all').on('click', function(){
                if(this.checked){
                    $('#table_demo3 :checkbox').prop('checked',true);
                }else{
                    $('#table_demo3 :checkbox').prop('checked',false);
                }
            });
            $('#table_demo3').find(':checkbox').on('click', function(){
                if(!this.checked){
                    $('#table_demo3').find('.select-all').prop('checked',false);
                }
            });
            //通过
            $(".pass").click(function () {
                var commentId = $(this).parent().prevAll().find(".hidden").attr("value");
                var url5 = getContextPath()+"/CommentController/passComment.press";
                $.post(url5, {"comment_id": commentId}, function (result) {
                    if (result.msg == "yes") {
                        alert("操作成功！")
                        window.location.reload();
                    } else {
                        alert("系统错误！操作失败！");
                    }
                }, "json");
            });
            //审核不通过
            $(".nopass").click(function () {
                var commentId = $(this).parent().prevAll().find(".hidden").attr("value");
                var url6 = getContextPath()+"/CommentController/nopassComment.press";
                $.post(url6, {"comment_id": commentId}, function (result) {
                    if (result.msg == "yes") {
                        alert("操作成功！")
                        window.location.reload();
                    } else {
                        alert("系统错误！操作失败！");
                    }
                }, "json");
            });
        },"json");
    });
    $("#trashcomm").click(function () {
        var data ={};
        $.post(url,data,function (result) {
            var Trashhtml ="";
            var Pagehtml ="";
            //动态添加待审核评论
            for(var i =0;i<result.commentBinList.length;i++){
                Trashhtml = Trashhtml +
                    "<tr><td>"+"<input name='dataItem' onclick='checkAll(this)' type='checkbox' />" +
                    "<input type='hidden' class='hidden' value='"+result.commentBinList[i].comment_id+"'/></td>" ;
                var fromwho=result.commentBinList[i].aUser.user_nickname;
                if(fromwho==null || fromwho == "")
                    Trashhtml = Trashhtml + "<td>"+""+"</td>";
                else
                    Trashhtml = Trashhtml + "<td>"+result.commentBinList[i].aUser.user_nickname+"</td>";
                var text=result.commentBinList[i].comment_text;
                if(text==null || text == "")
                    Trashhtml = Trashhtml + "<td>"+""+"</td>";
                else
                    Trashhtml = Trashhtml + "<td>"+result.commentBinList[i].comment_text+"</td>";
                Trashhtml = Trashhtml +
                    "<td>"+result.commentBinList[i].aContent.content_title+"</td>";
                var towho=result.commentBinList[i].aCommentParent.aUser.user_nickname;
                if(towho==null || towho == "")
                    Trashhtml = Trashhtml + "<td>"+""+"</td>";
                else
                    Trashhtml = Trashhtml +  "<td>"+result.commentBinList[i].aCommentParent.aUser.user_nickname+"</td>" ;
                Trashhtml = Trashhtml +
                    "<td>"+result.commentBinList[i].comment_date+"</td>" +
                    "<td>"+result.commentBinList[i].comment_status+"</td>" ;
                var status=result.commentBinList[i].comment_status;

                if(status=="已删除")
                    Trashhtml = Trashhtml +"<td>"+"<button type='button' class='pass btn btn-success'>恢复</button>&nbsp;&nbsp;<button type='button' class='remove btn btn-danger'>彻底删除</button>"+"</td></tr>"
                else if(status=="审核未通过")
                    Trashhtml = Trashhtml +"<td>"+"<button type='button' class='pass btn btn-success'>审核通过</button>&nbsp;&nbsp;<button type='button' class='remove btn btn-danger'>彻底删除</button>"+"</td></tr>"
            }
            Pagehtml=Pagehtml+
                "<tr><td colspan='8'>"+
                "<div class='pull-left'>"+
                "</div>" +
                "<div class='pull-right king-page-box'> " +
                "<p class='pull-left mt15'>共<span id='total'>12</span>条记录,当前第<span id='cur_page'>1</span>/<span id='total_page'>3</span>页</p> " +
                "<div class='holder pull-right ml15'> " +
                "<div class='king-jP'>" +
                "<a class='jp-previous jp-disabled'>«</a>" +
                "<a class='jp-current'>1</a>" +
                "<span class='jp-hidden'>...</span>" +
                "<a href='#' class=''>2</a><span class='jp-hidden'>...</span><a>3</a><a class='jp-next'>»</a></div> " +
                "</div> </div> </td> </tr>"

            $("#datas").html(Trashhtml);
            $("#datanum").html(Pagehtml);
            // 设置分页
            $("#table_demo3 .holder").jPages({
                containerID : "datas",
                previous : "«",
                next : "»",
                perPage : 4,
                delay : 10,
                callback: function(pages, items){
                    $('#total').text(items.count);
                    $('#cur_page').text(pages.current);
                    $('#total_page').text(pages.count);
                }
            });
            //全选
            $('#table_demo3').find('.select-all').on('click', function(){
                if(this.checked){
                    $('#table_demo3 :checkbox').prop('checked',true);
                }else{
                    $('#table_demo3 :checkbox').prop('checked',false);
                }
            });
            $('#table_demo3').find(':checkbox').on('click', function(){
                if(!this.checked){
                    $('#table_demo3').find('.select-all').prop('checked',false);
                }
            });
            //通过
            $(".pass").click(function () {
                var commentId = $(this).parent().prevAll().find(".hidden").attr("value");
                var url5 = getContextPath()+"/CommentController/passComment.press";
                $.post(url5, {"comment_id": commentId}, function (result) {
                    if (result.msg == "yes") {
                        alert("操作成功！")
                        window.location.reload();
                    } else {
                        alert("系统错误！操作失败！");
                    }
                }, "json");
            });
            $(".remove").click(function () {
                var commentId = $(this).parent().prevAll().find(".hidden").attr("value");
                var url7 = getContextPath()+"/CommentController/deleteComment.press";
                if (confirm("确定要永久删除吗？")) {
                    $.post(url7, {"comment_id": commentId},function (result) {
                        if (result.msg == "yes") {
                            alert("删除成功！")
                            window.location.reload();
                        } else {
                            alert("系统错误！删除失败！");
                        }
                    }, "json")
                }
            });
        },"json");
    });

});



